import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

public class FileReader {

	String freigabe;
	String satzstatus;
	String gegnerzug;
	String sieger;

	String[] daten = new String[4];

	public FileReader() throws FileNotFoundException, XMLStreamException {



	}

	String[] DatenAusLesen() throws XMLStreamException, FileNotFoundException {
		InputStream in = new FileInputStream(
				"C:\\Users\\beckmann\\Desktop\\server2spielerx.xml");
		XMLInputFactory factory = XMLInputFactory.newInstance();
		XMLStreamReader parser = factory.createXMLStreamReader(in);
		while (parser.hasNext()) {

			switch (parser.getEventType()) {

			case XMLStreamConstants.START_ELEMENT:

				if (parser.getLocalName().equals("freigabe")) {
					parser.next();
					freigabe = parser.getText();
					break;
				}
				if (parser.getLocalName().equals("satzstatus")) {
					parser.next();
					satzstatus = parser.getText();
					break;
				}
				if (parser.getLocalName().equals("gegnerzug")) {
					parser.next();
					gegnerzug = parser.getText();
					break;
				}
				if (parser.getLocalName().equals("sieger")) {
					parser.next();
					sieger = parser.getText();
					break;
				}
			}
			parser.next();
		}
		System.out.println(freigabe + " " + satzstatus + " " + gegnerzug + " "
				+ sieger);
		daten[0] = freigabe;
		daten[1] = satzstatus;
		daten[2] = gegnerzug;
		daten[3] = sieger;
		return daten;
	}
}
